package com.tao.auto.batchtao.home;

import com.tao.auto.batchtao.base.BaseFlow;
import com.tao.auto.batchtao.base.ParamContext;
import com.tao.auto.batchtao.home.account.HomeAccount;

/**
 * @author GLNC-taowenchen
 */
public abstract class AbstractHomeRegisterBaseFlow implements BaseFlow {

    @Override
    public void doSomething(String userName) {
        //获取账号信息
        ParamContext<HomeAccount> phone = getAccount(userName);
        if (phone.getData() == null) {
            return;
        }
        //1.获取校验码（获取短信验证码的时候需要带上获取的参数）
        ParamContext<String> sign = getSign();
        //2.发送短信验证码（post请求）
        sendCode(phone, sign);
        //获取验证码
        ParamContext<String> code = getCode(phone);
        //3.注册（post请求）
        register(phone, sign, code);
        save(phone);
    }

    protected abstract void save(ParamContext<HomeAccount> phone);

    protected abstract void register(ParamContext<HomeAccount> phone, ParamContext<String> sign, ParamContext<String> code);

    protected abstract ParamContext<String> getCode(ParamContext<HomeAccount> phone);

    protected abstract void sendCode(ParamContext<HomeAccount> phone, ParamContext<String> sign);

    protected abstract ParamContext<String> getSign();

    protected abstract ParamContext<HomeAccount> getAccount(String userName);


}
